package cn.rui.config;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * <pre>
 *     @author zwy
 *     @date 2019/3/29 15:54
 *     email        1092478224@qq.com
 *     desc         初始化用户与子站id
 * </pre>
 */
@Slf4j
@Component
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class InitAdmin implements InitializingBean {

    //private final RedisTemplate redisTemplate;

    @Override
    public void afterPropertiesSet() {
        //初始化超级管理员
//        log.info(">>>>>>>>> start init super admin account <<<<<<<<<");
//        if (redisTemplate.opsForValue().get(REDIS_KEY) == null) {
//            ManageUser manageUser = new ManageUser();
//            BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
//            manageUser.setLoginName(ADMIN);
//            manageUser.setId(USER_ID);
//            manageUser.setSiteId(SITE_ID);
//            manageUser.setSiteName(SITE_NAME);
//            manageUser.setPassword(encoder.encode(PASSWORD));
//            manageUser.setIsDeleted(IS_DELETED);
//            redisTemplate.opsForValue().set(REDIS_KEY, manageUser);
//        }
//        log.info(">>>>>>>>> init super admin account completed <<<<<<<<<");
//        //初始化子站
//        log.info(">>>>>>>>> start init sub site <<<<<<<<<");
//        Map<Integer, String> map = (Map<Integer, String>) redisTemplate.opsForValue().get("site");
//        if (map == null) {
////            map = new HashMap<>(32);
////            int i = 1;
////            map.put(i, "兰州新区");
////            map.put(i++, "甘肃");
////            map.put(i++, "兰州");
////            map.put(i++, "天水");
////            map.put(i++, "白银");
////            map.put(i++, "金昌");
////            map.put(i++, "嘉峪关");
////            map.put(i++, "庆阳");
////            map.put(i++, "平凉");
////            map.put(i++, "陇南");
////            map.put(i++, "定西");
////            map.put(i++, "武威");
////            map.put(i++, "张掖");
////            map.put(i++, "酒泉");
////            map.put(i++, "甘南");
////            map.put(i++, "临夏");
//            map.put (1,"一级");
//            map.put (2,"二级");
//            map.put (3,"三级");
//            redisTemplate.opsForValue().set("site", map);
//        }
//        log.info(">>>>>>>>> init sub site completed <<<<<<<<<");
    }
}
